import { MemberAddressItem } from '@/apis/address'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useAddressStore = defineStore('address',()=>{
      // 选中的收货地址
  const selectedAddress = ref({} as MemberAddressItem)
  
   // 修改收货地址的
  const changeSelectedAddress = (address:MemberAddressItem) =>{
    selectedAddress.value = address
  }

  return {
    selectedAddress,
    changeSelectedAddress
  }
},{
  persist:{
    storage:{
      setItem(key,value){
         uni.setStorageSync(key,value)
      },
      getItem(key){
        return uni.getStorageSync(key)
      }
    }
  }
})